package com.hong.nacosconsumer.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RefreshScope
@Slf4j
@RestController
@RequestMapping("/consumer")
public class ConsumerTestController {
    @Autowired
    private RestTemplate restTemplate;

    @Value("${useLocalCache:false}")
    private boolean useLocalCache;

    @RequestMapping("/get")
    public boolean get() {
        return useLocalCache;
    }

    @RequestMapping("/getProvider")
    public String getProvider() {
        return restTemplate.getForObject("http://nacosprovider/provider/get",String.class);
    }
}
